package ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import controller.MobilePlanSellAndBillSystem;
import customexceptions.ServiceAlreadyExistsException;
import dto.LineBillDTO;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class InvoiceUI extends javax.swing.JFrame {
	private JButton jButtonAccept;
	private MobilePlanSellAndBillSystem system;
	private JTextField jTextFieldInvoice;
	private JLabel jLabelInvoice;
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				InvoiceUI inst = new InvoiceUI();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	public InvoiceUI(){
		
	}
	public InvoiceUI(MobilePlanSellAndBillSystem system) {
		super();
		initGUI();
		this.system = system;
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			
			{
				jTextFieldInvoice = new JTextField();
				getContentPane().add(jTextFieldInvoice);
				jTextFieldInvoice.setBounds(111, 54, 333, 28);
			}
			{
				jLabelInvoice = new JLabel();
				getContentPane().add(jLabelInvoice);
				jLabelInvoice.setText("total invoices ");
				jLabelInvoice.setBounds(12, 59, 62, 16);
			}
				
			{
				jButtonAccept = new JButton();
				getContentPane().add(jButtonAccept);
				jButtonAccept.setText("Invoice");
				jButtonAccept.setBounds(200, 156, 84, 23);

				jButtonAccept.addActionListener(new ActionListener()
				{
					public void actionPerformed(ActionEvent evt) 
					{
						ArrayList<LineBillDTO> bills =  system.invoiceLines();
						for (LineBillDTO lineBillDTO : bills) {
							BillView view = new BillView(lineBillDTO);
							view.setVisible(true);
						}
						jTextFieldInvoice.setText(String.valueOf(bills.size()));
					}
				});
				
			}//5383217
			/*
					this.dni = dni;
					this.domicilio = domicilio;
					this.email = email;
			 */
			pack();
			this.setSize(506, 247);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
